﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WF.DAL;
using System.Data.SqlTypes;

namespace WF.Model
{
    [Serializable]
    public class PositionEntity : EntityBase<Position>
    {
        #region 构造函数

        public PositionEntity()
            : base()
        {
            this.SyncTime = SqlDateTime.MinValue.Value;
        }
        public PositionEntity(Position obj) : base(obj) { }
        #endregion

        #region 实现基类abstract属性

        public override string ID
        {
            get
            {
                return DbEntity.PositionID;
            }
            set
            {
                DbEntity.PositionID = value;
                this.SendPropertyChanged("PositionID");
            }
        }

        public override string DisplayName
        {
            get { return DbEntity.PositionName; }
        }

        #endregion


        #region Public 属性


        public string Name
        {
            get
            {
                return DbEntity.PositionName;
            }
            set
            {
                DbEntity.PositionName = value;
                this.SendPropertyChanged("PositionName");
            }
        }
        public string Path
        {
            get
            {
                return DbEntity.Path;
            }
            set
            {
                DbEntity.Path = value;
                this.SendPropertyChanged("Path");
            }
        }

        public string DeptID
        {
            get
            {
                return DbEntity.DeptID;
            }
            set
            {
                DbEntity.DeptID = value;
                this.SendPropertyChanged("DeptID");
            }
        }

        public string ParentID
        {
            get
            {
                return DbEntity.ParentID;
            }
            set
            {
                DbEntity.ParentID = value;
                this.SendPropertyChanged("ParentID");
            }
        }

        public short FlagDeptDirect
        {
            get
            {
                return DbEntity.FlagDeptDirect;
            }
            set
            {
                DbEntity.FlagDeptDirect = value;
                this.SendPropertyChanged("FlagDeptDirect");
            }
        }

        public short FlagDeleted
        {
            get
            {
                return DbEntity.FlagDeleted;
            }
            set
            {
                DbEntity.FlagDeleted = value;
                this.SendPropertyChanged("FlagDeleted");
            }
        }

        public short FlagPrincipal
        {
            get
            {
                return DbEntity.FlagPrincipal;
            }
            set
            {
                DbEntity.FlagPrincipal = value;
                this.SendPropertyChanged("FlagPrincipal");
            }
        }

        public int Number
        {
            get
            {
                return DbEntity.Number;
            }
            set
            {
                DbEntity.Number = value;
                this.SendPropertyChanged("Number");
            }
        }

        public string JobID
        {
            get
            {
                return DbEntity.JobID;
            }
            set
            {
                DbEntity.JobID = value;
                this.SendPropertyChanged("JobID");
            }
        }

        public string RoleID
        {
            get
            {
                return DbEntity.RoleID;
            }
            set
            {
                DbEntity.RoleID = value;
                this.SendPropertyChanged("RoleID");
            }
        }

        public System.DateTime? ModDate
        {
            get
            {
                return DbEntity.ModDate;
            }
            set
            {
                DbEntity.ModDate = DateTime.MinValue == value ? null : value; ;
                this.SendPropertyChanged("ModDate");
            }
        }

        public System.DateTime SyncTime
        {
            get
            {
                return DbEntity.SyncTime;
            }
            set
            {
                DbEntity.SyncTime = value;
                this.SendPropertyChanged("SyncTime");
            }
        }

        private string _DeptName;
        public string DeptName
        {
            get { return _DeptName; }
            set { _DeptName = value; this.SendPropertyChanged("DeptName"); }
        }
        private string _DeptFullName;
        public string DeptFullName
        {
            get { return _DeptFullName; }
            set { _DeptFullName = value; this.SendPropertyChanged("DeptFullName"); }
        }
        private string _ParentName;
        public string ParentName
        {
            get { return _ParentName; }
            set { _ParentName = value; this.SendPropertyChanged("ParentName"); }
        }
        private string _JobName;
        public string JobName
        {
            get { return _JobName; }
            set { _JobName = value; this.SendPropertyChanged("JobName"); }
        }
        #endregion

        [Obsolete("请使用 new PositionEntity(pos) ")]
        public static PositionEntity CreateEntityFromDb(WF.DAL.Position pos)
        {
            PositionEntity ret = null;
            if (pos != null)
            {
                ret = new PositionEntity(pos);
            }
            return ret;
        }

    }
}
